from tool.math.mymoudle import fibonacci


def get_positive_integer():
    """获取用户输入的正整数"""
    while True:
        try:
            x = int(input("请输入一个正整数: "))
            if x < 0:
                print("输入不能为负数，请重新输入！")
            else:
                return x
        except ValueError:
            print("无效输入，请输入一个整数！")


def main():
    print("斐波那契数列生成器")
    num = get_positive_integer()
    print(f"\n前{num}项斐波那契数列:")
    for i in range(num):
        print(f"F({i}) = {fibonacci(i)}")

if __name__ == "__main__":
    main()